# Maintainer : Sven-Hendrik Haase <svenstaro@gmail.com>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - explicitly link v5/v6 with libatomic

pkgname=openvdb
pkgver=8.0.1
pkgrel=3
pkgdesc='A large suite of tools for the efficient storage and manipulation of sparse volumetric data discretized on three-dimensional grids'
url='https://github.com/dreamworksanimation/openvdb'
arch=('x86_64')
license=('MPL')
depends=('boost-libs' 'intel-tbb' 'zlib' 'jemalloc' 'blosc' 'log4cplus' 'imath')
makedepends=('doxygen' 'boost' 'cmake' 'mesa' 'cppunit' 'glfw-x11' 'glu' 'python' 'python-numpy' 'ninja')
optdepends=('glfw: for tools'
            'glu: for tools'
            'python-numpy: python module')
source=("$pkgname-$pkgver.tar.gz::https://github.com/dreamworksanimation/openvdb/archive/v${pkgver}.tar.gz"
         openvdb-openexr3.patch)
sha512sums=('6a5a8b637429295efa72494aef82ff92dd83092591b713f56930ccf4aab3a33806d1263bfd090c27239eab97b4fdc053288dc545e631f8a7d4ca180a32331be2'
            'bc7a0e4c7ef00b620e62097f56a741f4924d1465528d5fabd52fefe1c981d109389c7c75056508bc32353f0daa8305367c9a52e941b7ec1fbef865ee5719615a')

prepare() {
  patch -d $pkgname-$pkgver -p1 < openvdb-openexr3.patch
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  [[ $CARCH == "arm" || $CARCH == "armv6h" ]] && LDFLAGS="-latomic $LDFLAGS"
  cmake \
    -Bbuild \
    -GNinja \
    -DUSE_NUMPY=ON \
    -DUSE_LOG4CPLUS=ON \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DOPENVDB_BUILD_PYTHON_MODULE=ON \
    -DOPENVDB_BUILD_DOCS=ON \
    -DOPENVDB_BUILD_UNITTESTS=OFF

  ninja -C build
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}/build"

  DESTDIR="${pkgdir}" ninja install
}

# vim:set sw=2 sts=2 et:
